package com.duowei.dw_pos.dialog;

import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.support.v7.app.AppCompatDialogFragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import com.duowei.dw_pos.R;
/**
 * A simple {@link Fragment} subclass.
 */
public class GuqingFragment extends AppCompatDialogFragment {

    public GuqingFragment() {
        // Required empty public constructor
    }

    public static GuqingFragment newInstance(String str) {
        Bundle args = new Bundle();
        str=str.replaceAll("]","").replaceAll("\\[","").
        replaceAll("xmmc","品名").replaceAll("\\{","").
        replaceAll("\\}","\n");
        args.putString("str",str);
        GuqingFragment fragment = new GuqingFragment();
        fragment.setArguments(args);
        return fragment;
    }
    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
                             Bundle savedInstanceState) {
        // Inflate the layout for this fragment
        getDialog().getWindow().setBackgroundDrawableResource(android.R.color.transparent);
        getDialog().setCanceledOnTouchOutside(false);
        String str = getArguments().getString("str", "");
        View inflate = inflater.inflate(R.layout.fragment_guqing, container, false);
        TextView tvMsg = (TextView) inflate.findViewById(R.id.tv_msg);
        tvMsg.setText(str);
        inflate.findViewById(R.id.btnClose).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                dismiss();
            }
        });
        return inflate;
    }
}
